package jax.rx;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.File;
import java.net.URI;

@Path("/user")
public class UserResource {

    @GET
    @Produces("application/xml")
    public Response getUser() {
        return Response.created(URI.create("/dd")).build();
    }

    @GET
    public Response getDefaultUser(@DefaultValue("yancy")
                                       @QueryParam("name") String name) {
        System.out.println("getDefaultUser: " + name);
        return Response.created(URI.create("/dd")).build();
    }

    @GET
    @Path("/index")
    public Response getFile() {
        File file = new File("G:\\test-env\\how_tomcat_works.pdf");
        return Response.ok(file, MediaType.APPLICATION_OCTET_STREAM)
            .header("Content-Disposition", "attachment; filename=index.jsp" ) //optional
            .build();
    }
}